function isObj(object) {
    return object && typeof(object) == 'object' && Object.prototype.toString.call(object).toLowerCase() == "[object object]";
}

function isArray(object) {
    return object && typeof(object) == 'object' && object.constructor == Array;
}

function getLength(object) {
    var count = 0;
    for(var i in object) count++;
    return count;
}
//校验变化
function checkDataChange(form,oneInfo,formData) {
    return  Compare(formData?formData:getFormData(form),oneInfo);
}
function Compare(objA, objB) {
    console.log("objA");
    console.log(objA);
    console.log("objB");
    console.log(objB);
    if(!isObj(objA) || !isObj(objB)) return false; //判断类型是否正确
    // if((isArray(objA)) && (isArray(objB)) && (getLength(objA) != getLength(objB))) return false; //判断长度是否一致
    return CompareObj(objA, objB, true); //默认为true
}
// 比较是以A为准的，
function CompareObj(objA, objB, flag) {
    for(var key in objA) {
        console.log("objA-key:" + key + ",value:" + objA[key]);
        console.log("objB-key:" + key + ",value:" + objB[key]);
        // 两个对象的null和''是一样true
        if((objA[key]=='' || objA[key]==null  )&&(objB[key]=='' || objB[key]==null )){
            continue;
        }
        if(!flag) //跳出整个循环
            break;
        if(!objB.hasOwnProperty(key)) {
            flag = false;
            break;
        }
        if(!isArray(objA[key])) { //子级不是数组时,比较属性值
            if(objB[key] != objA[key]) {
                flag = false;
                break;
            }
        } else {
            if(!isArray(objB[key])) {
                flag = false;
                break;
            }
            var oA = objA[key],
                oB = objB[key];
            if(oA.length != oB.length) {
                flag = false;
                break;
            }
            for(var k in oA) {
                if(!flag) //这里跳出循环是为了不让递归继续
                    break;
                flag = CompareObj(oA[k], oB[k], flag);
            }
        }
    }
    return flag;
}
function equalArray(arrayA,arrayB) {
    console.log(arrayA);
    console.log(arrayB);
    var result=true;
    if(!isArray(arrayA)||!isArray(arrayB)||!arrayA&&arrayB||arrayA&&!arrayB||arrayA.length!=arrayA.length) return false;
    for (key in arrayA) {
        if($.inArray(arrayA[key], arrayB)==-1&&$.inArray(arrayA[key]-0, arrayB)==-1){
            result=false;
            return;
        }
    }
    if(result){
        for (key in arrayB) {
            if($.inArray(arrayB[key], arrayA)==-1&&$.inArray(arrayB[key]+'', arrayA)==-1){
                result=false;
                return;
            }
        }
    }
    return result;
}
